/*------------------------------------------------------*/
/*                                                      */
/* Copyright (C)	sky-mobi.com                        */
/* All rights reserved                                  */
/*                                                      */
/* Author   tristan.yang                                */
/*                                                      */
/* History  2012-06-26 created                          */
/*                                                      */
/*------------------------------------------------------*/

#ifndef __POINT_TVL_H__
#define __POINT_TVL_H__

#include "pointBase.h"
#include "connprovider.h"
#include "tlv12.h"
#include "room_procotol.h"
#include "json/json.h"

class CPointTlv 
: public CPointBase 
, public IConnectionSink
{
public:
	CPointTlv(CPointSink* pSink, DWORD inType);
	virtual ~CPointTlv();
	
	TransportAddress GetPeerAddr();
	RtResult SetConnection(void *pConnection);

	virtual void DisconnectSelf();

public:
	void SendJson(uint16_t ucmd, int16_t iresult, const string& strJson);

protected:
	// from IConnectionSink	
	virtual void OnReceiveData(CRtMessageBlock& aData, IConnection* pConn);
	virtual void OnDisconnect(RtResult aReason, IConnection* pConn);
	virtual void OnSend(IConnection* pConn);
	
protected:
	void	OnKeepLiveReq(char* szJson);
	void	OnEnterRoomReq(char* szJson);
	void	OnTextReq(char* szJson);


protected:
	virtual RtResult SendData(CRtMessageBlock &aData);
	
private:
	void OnReceiveTlv(LPBYTE pdata, INT ilen);
	

	
private:
	CRtAutoPtr<IConnection>	m_pConnect;
	CRtString				m_strMsgBuf;

	TransportAddress		m_peerAddr;
};

#endif//__POINT_TVL_H__
